<template>
  <header class="app-header">
    <div class="container">
      <RouterLink to="/" class="logo">
         <!-- <img src="@/assets/img/logo.png" alt=""> -->
         <p style="font-size: xx-large;color: pink">
          <img src="@/assets/img/logo.png" alt="" style="height: 40px;width: 130px;">
          潮流共创社区
         </p>
      </RouterLink>
      <div class="search">
        <input
          placeholder="请输入要搜索的内容"
          maxlength="15"
          type="text"
          v-model="searchs"
          @keyup.enter="buttom_search"
        />
        <div class="button" @click="buttom_search">搜索</div>
      </div>
      
    </div>
  </header>
</template>

<script>
import { ref, inject } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
export default {
  name: "AppHeader",
  setup() {
    // const ceshi = inject("reload");
    const router = useRouter();
    const searchs = ref(null);
    const buttom_search = () => {
      if (searchs.value) {
        router.push(`/search/${searchs.value}`);
        // ceshi()
      } else {
        ElMessage({
          showClose: true,
          message: "请输入要搜索的信息",
          type: "warning",
        });
      }
      searchs.value = "";
    };
    return { searchs, buttom_search };
  },
};
</script>

<style scoped lang="less">
.app-header {
  height: 70px;
  padding-top: 6px;
  background: #fff;
  line-height: 70px;
  .container {
    display: flex;
    flex-direction: row;
    justify-content: space-between; 
    align-items: center;
  }
  .search {
    width: 220px;
    height: 35px;
    display: flex;
    margin-left: 10px;
    // line-height: 45px;
    input {
      flex: 1;
      width: 170px;
      padding-left: 5px;
      border: 1px solid #f4f4f4;
      color:black;
      font-size: 14px;
      border: 1px solid grey; /* 加黑边框 */
      padding-left: 20px; /* 调整内边距 */
    }
    .button {
      width: 60px;
      height: 35px;
      line-height: 35px;
      text-align: center;
      margin: auto;
      background:pink;
      color: #fff;
      font-size: 15px;
      border: 1px solid pink;
      user-select: none;
    }
  }
}
</style>